package per.chenyl.framework.persistence.common.util;

import per.chenyl.framework.persistence.entity.anno.Entity;

public class ClassUtil {
    private ClassUtil(){}
    /**
     * @param cl 实体对象Class
     * @return java.lang.String
     * @desc 获取表名
     * @method getTableName
     * @author YulinChen
     * @date 2020/4/23 8:56
     */
    public static String getTableName(Class<?> cl) {
        final Entity tableAnno = cl.getAnnotation(Entity.class);
        final String tableName = tableAnno.value();
        if (tableName.length() < 1) {
            throw new RuntimeException("Entity [" + cl.getName() + "] 对应的表名不可为空 !");
        }
        return tableName;
    }
}
